package blackithei.TCP;

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.net.ServerSocket;
import java.net.Socket;

public class ServerDemo2 {
    public static void main(String[] args) throws IOException {
        ServerSocket so=new ServerSocket(10001);
        Socket accept = so.accept();
        InputStream in = accept.getInputStream();
        int by;
        while((by=in.read())!=-1){
            System.out.println((char) by);
        }

        BufferedWriter bf=new BufferedWriter(new OutputStreamWriter(accept.getOutputStream()));
        bf.write("收到了");
        bf.flush();
        bf.close();

        in.close();
        accept.close();
        so.close();
    }
}
